﻿$(document).ready(function () {
    jQuery("#part-five").slide({mainCell:".scroll-content ul",effect:"leftLoop",autoPlay:true,delayTime:700,mouseOverStop:false});
	jQuery("#part-ten").slide({mainCell:".scroll-content2 ul",effect:"leftLoop",autoPlay:true,delayTime:700,mouseOverStop:false});
	jQuery(".slideBox").slide({mainCell:".mybd ul",effect:"leftLoop",autoPlay:true,delayTime:700,mouseOverStop:false});
    change_screen();
    gotoGoal($('#part-one'));
})
//全屏运算
function change_screen() {
    var screenHeight = $(window).height();
    $('#main > div').height(screenHeight);
	$('#main').height(screenHeight);
    $('.container').each(function () {
        var mytop = 0;
        if (screenHeight > $(this).height()) {

            mytop = (screenHeight - $($(this)).height()) / 2;
        }
        $(this).css({ 'top': mytop + 'px' });
    });
}
$(window).resize(function () {
    change_screen();
})
//滚动导向
function gotoGoal(obj) {
	removeClass();
    $body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
    var myTop = obj.offset().top;
    $('#main > div').removeClass('this-here');
    obj.addClass('this-here');
    var index = $('#main > div').index($('.this-here'));
    //$('.direct-bar a').removeAttr('style');
    //$('.direct-bar a:eq(' + index + ')').css({ 'background-color': 'white' });
	$('.direct-bar a').removeClass('b50');
	$('.direct-bar a:eq(' + index + ')').addClass('b50');
    $body.animate({ scrollTop: myTop }, 500);
	if(index ==0){
		$('#word').addClass('animated bounceIn');
	 	$('#bbpic').addClass('animated fadeInLeft');
		$('#bottom_box').addClass('animated fadeInUp');
	}else if(index ==1){
	    $('#circle_bg').addClass('animated zoomIn');
		$('#y100').addClass('animated fadeInDownBig');
		$('#baby').addClass('animated fadeInLeft');
		$('#word2').addClass('animated tada');
	}else if(index ==2){
	    $('#c3_1').addClass('animated zoomIn');
		$('#c3_2').addClass('animated zoomIn');
		$('#c3_3').addClass('animated zoomIn');
		$('#word_1').addClass('animated zoomIn');
		$('#word_2').addClass('animated zoomIn');
		$('#word_3').addClass('animated zoomIn');
	}else if(index ==3){
	    $('#c4_1').addClass('animated bounceIn');
		$('#c4_2').addClass('animated bounceIn');
		$('#c4_3').addClass('animated bounceIn');
		$('#c4_5').addClass('animated bounceIn');
		$('#c4_6').addClass('animated bounceIn');
	}else if(index ==4){
	    $('#word5').addClass('animated tada');
	}else if(index ==5){
		$('#c6_4').addClass('animated zoomIn');
		$('#c6_5').addClass('animated zoomIn');
		$('#c6_6').addClass('animated zoomIn');
	    $('#word6').addClass('animated tada');
		$('#word6_1').addClass('animated fadeIn');
		$('#word6_2').addClass('animated fadeIn');
		$('#word6_3').addClass('animated fadeIn');
	}else if(index ==6){
		$('#c7_1').addClass('animated zoomIn');
		$('#c7_2').addClass('animated zoomIn');
	    $('#c7_3').addClass('animated zoomIn');
		$('#word7_1').addClass('animated fadeIn');
		$('#word7_2').addClass('animated fadeIn');
		$('#word7_3').addClass('animated fadeIn');
	}else if(index ==7){
		$('#c8_1').addClass('animated rotateIn');
		$('#c8_2').addClass('animated tada');
	    $('#c8_3').addClass('animated fadeIn');
	}else if(index ==8){
		$('#c9_1').addClass('animated rotateIn');
		$('#c9_3').addClass('animated fadeIn');
		$('#c9_2').addClass('animated tada');
	}else if(index ==9){
		$('#word10_1').addClass('animated tada');
		$('#word10_2').addClass('animated bounce');
	}else if(index ==10){
		$('#c17_3').addClass('animated fadeInLeft');
		$('#c17_4').addClass('animated fadeInUp');
		$('#c17_5').addClass('animated fadeInUp');
		$('#c17_6').addClass('animated fadeInUp');
		$('#c17_7').addClass('animated fadeInUp');
		$('#c17_8').addClass('animated fadeInUp');
		$('#c17_9').addClass('animated rotateIn');
		$('#c17_10').addClass('animated rotateIn');
		$('#c17_11').addClass('animated rotateIn');
		$('#c17_1').addClass('animated fadeIn');
	    $('#c17_2').addClass('animated fadeIn');
	}else if(index ==11){
		$('#c11_1').addClass('animated tada');
		$('#c11_2').addClass('animated fadeIn');
		$('#c11_3').addClass('animated fadeInLeft');
		$('#c11_4').addClass('animated fadeInRight');
	}else if(index ==12){
		$('#c12_1').addClass('animated tada');
		$('#c12_2').addClass('animated fadeIn');
		$('#c12_3').addClass('animated fadeInLeft');
		$('#c12_4').addClass('animated fadeInRight');
	}else if(index ==13){
		$('#c13_1').addClass('animated flipInX');
		$('#c13_2').addClass('animated flip');
	}else if(index ==14){
		$('#c14_1').addClass('animated flipInX');
		$('#c14_2').addClass('animated zoomInDown');
	}else if(index ==15){
		$('#c16_1').addClass('animated flipInX');
		$('#c16_2').addClass('animated fadeInLeft');
		$('#c16_3').addClass('animated fadeInRight');
		$('#c16_4').addClass('animated fadeInUp');
	}
}
function removeClass(){
	$('.animated').removeClass();
}
//判断滚动方向
$("html,body").on("mousewheel", function (event, intDelta) {
    var $this = $(this), timeoutId = $(this).data('timeoutId');
    if (timeoutId) {
        clearTimeout(timeoutId);
    }
    $this.data('timeoutId', setTimeout(function () {
        if ($('#sb-container').length > 0) {
            if ($('#sb-container').is(':visible') == false) {
                change_scroll(intDelta);
            }
        }
        else {
            change_scroll(intDelta);
        }
    }, 150));
});
function change_scroll(intDelta)
{
    if (intDelta > 0) {
        if ($('.this-here').prev().length > 0) {
            gotoGoal($('.this-here').prev());
        }
    }
    else {
        if ($('.this-here').next().next().length > 0) {
            gotoGoal($('.this-here').next());
        }
    }
}
//单选操作
function change_radio() {
	$('.btn-group a').on('click', function () {
		$(this).parent().find('span').remove();
		$(this).parent().find('a').removeClass('active');
		$(this).append('<span class="glyphicon glyphicon-ok"></span>');
		$(this).addClass('active');
		$(this).find('input').prop('checked', true);
	});
	$('.btn-group').each(function () {
		$(this).find('a:eq(0)').trigger('click');
	});
}